package Interface.lianxi03;

interface  A{
    void moA();
}
interface B extends  A{
    void B();
}
interface  C {
 void C();
}
interface  D extends  B,C{
    void D();

}
class E implements  D{


    @Override
    public void moA() {
        System.out.println("A的实现方法");
    }

    @Override
    public void B() {
        System.out.println("B的实现方法");
    }

    @Override
    public void C() {
        System.out.println("C的实现方法");
    }

    @Override
    public void D() {
        System.out.println("D的实现方法");
    }
}
public class TestInterface {
    public static void main(String[] args) {
    A a = new E();
        B b = new E();
        C c = new E();
        D d = new E();
        //向下转型
        if (a instanceof E) {
            E e = (E) a;
            e.moA();
        } else if (b instanceof E) {
            E e = (E) b;
            e.B();
        } else if (c instanceof E) {
            E e = (E) c;
            e.C();
        } else if (d instanceof E){
            E e = (E) d;
            e.D();
        }else {
            System.out.println("转型失败");
        }
        System.out.println(c instanceof A);
        System.out.println(c instanceof B);
        System.out.println(c instanceof C);
        System.out.println(c instanceof D);
        System.out.println(c instanceof E);
    }
}
